/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.entities;

import java.sql.Date;
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.NumberFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Ignacio
 */
public class pegawaiTableModel extends AbstractTableModel {
private List<Pegawai> pegList = new ArrayList<Pegawai>();
    public pegawaiTableModel(List<Pegawai> pegawaiList){
       this.pegList=pegawaiList;
    }
    @Override
    public int getRowCount() {
        return pegList.size();
    }

    @Override
    public int getColumnCount() {
       return 9;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Pegawai pegw = pegList.get(rowIndex);
        NumberFormat number = NumberFormat.getCurrencyInstance();
        switch (columnIndex) {
            case 0: 
                return pegw.getNIP();               
            case 1:
                return pegw.getNama();
            case 2:
                return pegw.getTempatLahir();
            case 3:
                return pegw.getTanggalLahir();
            case 4:
                return pegw.getJenisKelamin();
            case 5:
                return pegw.getPendidikan();
            case 6:
                return pegw.getTipePegawai();
            case 7:
                return pegw.getGolongan();
            case 8:
                return number.format(pegw.getGajiPokok());
            default:
                return "";
        }
    }
    @Override
    public String getColumnName(int column){
        switch(column){
            case 0:
                return "NIP";
            case 1:
                return "Nama";
            case 2:
                return "Tempat Lahir";
            case 3:
                return "Tanggal Lahir";
            case 4:
                return "Jenis Kelamin";
            case 5:
                return "Pendidikan";
            case 6:
                return "Status Pegawai";
            case 7:
                return "Golongan";
            case 8:
                return "Gaji Pokok";
            default:
                return "";
                
        }
    }
    
}
